// 47
package org.hwadee.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/*
页面管理
 */
@Controller
@RequestMapping("/page")
public class PageController {

//    @Autowired
//    MovieService movieService;
//
//    //如果大家选择的是 JSP+EL，可以在 Controller 中先查找到数据，再跳转界面
//    @RequestMapping("/toMain")
//    public String main(HttpSession session) {
//        List<Movie> movies = movieService.getAllMovies();
//        session.setAttribute("movies", movies);
//        return "main";
//    }

    //跳转主界面
    @RequestMapping("/main")
    public String main() {
        return "main";
    }

    @RequestMapping("/manager")
    public String manager() {
        return "manager";
    }

    @RequestMapping("/register")
    public String register() {
        return "register";
    }

    @RequestMapping("/login")
    public String login() {
        return "login";
    }

    //让映射路径上的地址和参数匹配并自动响应视图
    //http://localhost:8080/page/common/main -> main.jsp
    //http://localhost:8080/page/common/register -> register.jsp
    @RequestMapping("/common/{page}")
    public String common(@PathVariable("page") String page) {
        //视图解析器：/WEB-INF/jsp/{page}.jsp
        return page;
    }

}
